package cn.itheima.student.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itheima.student.daomain.PageBean;
import cn.itheima.student.service.StudentService;
import cn.itheima.student.service.impl.StudentServiceImpl;


public class StudentPageServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
     
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset =utf-8");
		
		String current = request.getParameter("currentPage");
		StudentService service = new StudentServiceImpl();
		PageBean pageBean = service.getPage(current);
		
		request.setAttribute("page", pageBean);
		request.getRequestDispatcher("/student/page.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
